package com.bbc.wigeth;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by Administrator on 2017/9/27.
 */

public class MyFreeView extends View {
    private String text = "你好额";

    public MyFreeView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setColor(Color.RED);
        paint.setStrokeWidth(20);
        paint.setStyle(Paint.Style.FILL);
        canvas.drawRect(new Rect(30, 50, 200, 200) , paint);
        paint.setColor(Color.BLUE);
        canvas.drawText(text, 50, 300, paint);
    }
}
